(function(){
	$.fn.deserialize=function(data){
		for(var key in data){
			if(this.find("[name="+key+"]").attr("type")=="radio"){
				var radios = this.find("[name="+key+"]");
				for(var i=0;i<radios.length;i++){
					if($(radios[i]).val()==data[key]){
						$(radios[i]).attr("checked",true);
					}
				}
			}else if(this.find("[name="+key+"]").attr("type")=="checkbox"){
				var chencboxs = this.find("[name="+key+"]");
				var value = data[key];
				for(var i=0;i<value.length;i++){
					for(var j=0;j<chencboxs.length;j++){
						if(value[i]==$(chencboxs[j]).val()){
							$(chencboxs[j]).attr("checked",true);
						}
					}
				}
				
			}else{
				var tagName = this.find("[name="+key+"]")[0].tagName;
				if(tagName=="INPUT" || tagName=="TEXTAREA" || tagName=="SELECT"){
					this.find("[name="+key+"]").val(data[key]);
				}else{
					this.find("[name="+key+"]").text(data[key]);
				}
				
			}
		}
	}
})(jQuery)
